package nconv.convert.plugins;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by xiaobyu on 5/16/2016.
 */
public class P29212 extends DefaultTGPPConvertPlugin{
    Set<String> avpDefHeading = new HashSet<>(Arrays.asList(
            "Revalidation-Time (ALL Access Types)",
            "Rule-Activation-Time (ALL Access Types)",
            "Rule-Deactivation-Time (ALL Access Types)",
            "Session-Release-Cause (All access types)",
            "Conditional-APN-Aggregate-Max-Bitrate (All access types)",
            "CS-Service-QoS-Request-Identifier",
            "CS-Service-QoS-Request-Operation",
            "CS-Service-Resource-Result-Operation",
            "CS-Service-Resource-Failure-Cause",
            "CS-Service-Resource-Report"));

    @Override
    public String getReplacedAVPDefOrDiameterMessageHeading(String original) {
        original = original.trim();
        if (avpDefHeading.contains(original.trim())) {
            int spacePos = original.indexOf(' ');
            if (spacePos > 0) {
                return original.substring(0, spacePos) + " AVP" + original.substring(spacePos);
            } else {
                return original + " AVP";
            }
        }
        return original;
    }

    public String getAVPNameInTable(String avpName) {
        if (avpName.equals("CS-Service-Qos-Request-Identifier")) {
            return "CS-Service-QoS-Request-Identifier";
        }

        return avpName;
    }
}
